<?php 
class web_login 
{ 
	// 登录
	function login_in() 
	{ 
		global $v_file;
		require($v_file);
	}
	// 登录回调
	function login_do()
	{
		global $mysql_conn;
		$bot_name = $_POST['bot_name'];
		$bot_password = $_POST['bot_password'];
		$sql = "SELECT * from `bot` WHERE `bot_name` = '".$bot_name."'";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		if (!empty($row)) {
			if ($bot_password == $row['bot_password']) {
				$bot_id = $row['bot_id'];					// 机器人id
				$bot_server_id = $row['bot_server_id'];		
				$bot_user_id = $row['bot_user_id'];
				$bot_wxid = $row['bot_wxid'];
				$bot_statue	= $row['bot_statue'];			// 机器人是否正在执行
				$bot_work_data = $row['bot_work_data'];		// 有效期
				setcookie("bot_id", $bot_id, time()+3600);
				setcookie("bot_name", $bot_name, time()+3600);
				setcookie("bot_server_id", $bot_server_id, time()+3600);
				setcookie("bot_user_id", $bot_user_id, time()+3600);
				setcookie("bot_wxid", $bot_wxid, time()+3600);
				setcookie("bot_statue", $bot_statue, time()+3600);
				setcookie("bot_work_data", $bot_work_data, time()+3600);
				echo "3";//密码正确
			} else {
				echo "2";//密码不正确
			}
		} else {
			echo  "1";//用户不存在
		}
	}
	function login_exit()
	{
		setcookie("bot_name", "", time()-3600);
		setcookie("bot_server_id", "", time()-3600);
		setcookie("bot_user_id", "", time()-3600);
		setcookie("bot_wxid", "", time()-3600);
		setcookie("bot_statue", "", time()-3600);
		setcookie("bot_work_data", "", time()-3600);
		echo "1";
	}
}
/* End of file democontroller.php */ 